package learn_250211;

public class choose {
    public static void main(String[] args){
        int[] a = {3,4,1,2,5};
        choose_sort(a);
        for (int i : a) {
            System.out.print(i + " ");
        }
    }

    public static  void choose_sort(int[] a){
        for(int i=0;i<a.length;i++){
            int tmp = a[i];
            int min = tmp;
            int min_pos = -1 ;
            for(int j = i+1;j<a.length;j++){
                    if(a[j]<min){
                        min = a[j];
                        min_pos = j;
                    }
                }

            if (min_pos != -1 ){
                a[i] = a[min_pos];
                a[min_pos] = tmp;
            }
            }
        }
}
